package com.itheima.tliasproject.mapper;


import com.itheima.tliasproject.pojo.Clazz;
import com.itheima.tliasproject.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {

    //分页查询全部班级数据

    List<Clazz> list(ClazzQueryParam clazzQueryParam);

    //新增班级
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void updateclazz(Clazz clazz);

    //判断该班级下是否有学生
    @Select("select count(*) from student where clazz_id = #{id}")
    Integer count(Integer id);
    //删除班级
    @Delete("delete from clazz where id = #{id}")
    void delete(Integer id);
    //根据ID查询班级数据进行回显
    @Select("select c.* from clazz c  where c.id = #{id} ")
    Clazz selectById(Integer id);
    @Update("update clazz set name=#{name},room=#{room},begin_date=#{beginDate},end_date=#{endDate},master_id=#{masterId},subject=#{subject} where id=#{id}")
    void update(Clazz clazz);
    //查询所有班级
    @Select("select * from clazz")
    List<Clazz> listall();
}
